package cn.txm.user.controller;

import cn.txm.basic.util.RedisUtils;
import cn.txm.pet.domain.Pet;
import cn.txm.user.domain.User;
import cn.txm.user.domain.UserAddress;
import cn.txm.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
public class UserController {
    @Autowired
    private IUserService userService;

    /**
     * 前台：根据用户id查询用户地址
     * @param request
     * @return
     */
    @GetMapping("/userAddress")
    public List<UserAddress> loadAll(HttpServletRequest request){
        User user = RedisUtils.INSTANCE.getUser(request, User.class);
        return userService.loadUserAddress(user.getId());
    }


}
